<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>App开发平台</title>
	<link rel="stylesheet" type="text/css" href="../../css/bootstrap.min.css">
	<link
    rel="stylesheet"
    href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.0.0/animate.min.css"
  />
	<style type="text/css">
		body{
			padding: 0px;
			margin: 0px;
			text-align: center;
			background: url(../../img/bg1.jpg) no-repeat;
			background-size: 100% 100%;
			background-attachment:fixed;
		}
		form{
			display: inline-block;
			width: 450px;
			height:300px;
			margin-top: 150px;
			padding-top: 20px;
		}
		h1{
			margin-bottom: 30px;
			font-size: 30px;
			color: #0EAED6;
		}
		/*footer*/
		footer{
			position: absolute;
			bottom: 0;
			left: 40%;
			width: 20%;
			color: white;
		}
	</style>
</head>
<body>

	
	<form class="form-horizontal panel panel-default" id="login_form">
		<h1 class="animate__animated animate__bounce">---App开发平台---</h1>
		<div class="form-group">
			    <label for="inputEmail1" class="col-sm-3 control-label">账号</label>
			    <div class="col-sm-8">
			      <input type="text" class="form-control" name="devName" id="inputEmail1" placeholder="请输入用户名" >
			    </div>
			  </div>

			   <div class="form-group">
			    <label for="inputEmail3" class="col-sm-3 control-label">密码</label>
			    <div class="col-sm-8">
			      <input type="text" class="form-control" name="devPassword" id="inputEmail3" placeholder="请输入密码" >
			    </div>
			  </div>

			<div class="form-group">
				<input id="login" type="button" class="btn btn-primary" value="登录" />
				  <a class="btn btn-default" href="../index.html">返 回</a>
			</div>
	</form>

	<footer>@2020 AllRights Reserved</footer>
	<script type="text/javascript" src="../../js/jquery-3.4.1.min.js"></script>
	<script type="text/javascript" src="../../js/bootstrap.min.js"></script>
	<script type="text/javascript">
		$(function () {
			$("#login").bind("click",function () {
				let data = {"devName": $("#inputEmail1").val(), "devPassword": $("#inputEmail3").val(), "userType": "developer"}
				console.log(JSON.stringify(data))
				$.ajax({
					url:"/user/login",
					type:"POST",
					contentType: "application/json",
					dataType : 'json',
					data: JSON.stringify(data),
					success:function (data) {
						console.log(data)
						if (data.code === 1) {
							//全局存储token
							window.localStorage["token"] = data.data;
							window.location.href = './index.html'
						} else if (code === 10002) {
							alert('参数为空')
						} else if (code === 20002) {
							alert('密码错误')
						}
					},
					error:function () {

					}
				})
				return false;
			});
		})

	</script>
</body>
</html>